package com.wing.common.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.wing.contract.model.entity.ContractCategory;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 合同
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("com_contract")
public class Contract extends BaseEntity<Contract> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {

        /**
        * 待签约
        */
        staySign(0,"待签约"),
        /**
        * 已签约
        */
        hasSign(1,"已签约");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 名称
     */
    private String name;

    /**
     * 编号
     */
    private String code;

    /**
     * 合同主体类型
     */
    private ContractCategory.Type type;

    /**
     * 合同分类ID
     */
    private Long contractCategoryId;

    /**
     * 签约主体ID
     */
    private Long subjectId;

    /**
     * 客户签约人ID
     */
    private Long contactsId;

    /**
     * 我方签约人ID
     */
    private Long contractor;

    /**
     * 签约金额
     */
    private BigDecimal amount;

    /**
     * 附件
     */
    private String attachment;

    /**
     * 信息审批人ID
     */
    private Long approver;

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 合同主体类型描述
     */
    @TableField(exist = false)
    private String typeDesc;

    public String getTypeDesc() {
        return type == null ? null : type.getDesc();
    }


}
